using Godot;
using System;

public partial class BaseWeaponAnimate : Node2D
{
    [Signal]
    public delegate void OnAttackEndEventHandler();

    AnimationPlayer animationPlayer;

    public override void _Ready()
    {
        base._Ready();
        animationPlayer = GetNode<AnimationPlayer>("AnimationPlayer");
        animationPlayer.AnimationFinished += OnAnimationFinishedHandler;
    }

    private void OnAnimationFinishedHandler(StringName animName)
    {
        if (animName != "RESET")
        {
            EmitSignal(SignalName.OnAttackEnd);
        }
    }

    public void Play(string name, WeaponEntity wp)
    {
        animationPlayer.Play(name);
        if (name != "RESET")
        {
            AudioManager.PlayEffect(wp.Sound);
        }
    }
}
